package com.gwcloud.leetcode.tags.tree;

/** 
* @ClassName   : Leetcode1351 
* @author      : ganwei 
* @date        : 2020年6月17日 
* @Description : TODO 
*/
public class Leetcode1351 {
    public int countNegatives(int[][] grid) {
    	int m = grid.length;
    	int n = grid[0].length;
    	int i = 0, j = n-1;
    	int sum = 0;
    	while(i >= 0 && j >= 0 && i < m && j < n) {
    		if(grid[i][j] >= 0) {
    			i++;
    		}else {
    			sum += m-i;
    			j--;
    		}
    	}
    	return sum;
    }
}
